// 模块：送货明细，退货补货
import { FileListType } from '@renderer/types/global'
import axios from 'axios'
const modelUrl = '/produce'
// 送货单
export interface ProductDetailReq {
  deliveryOrderDetailId: string
  deliveryOrderId: string
  deliveryOrderCode: string
  materialStockId: string
  qty?: number
  unitPrice: number
  amt: number
  unit: string
  materialName: string
  spec: string
  materialCode: string
  materialDesc: string
  fluteType: string
  crimpLine: string
  outboundStatus: number
  remark: string
  orderCode: string
}
export interface DeliveryReq {
  deliveryOrderId?: string
  customerId: string
  customerName: string
  deliveryDate: string
  isInclTax: number
  sellersName: string
  sellersId: string
  transportCarNo: string
  invoiceStatus: string
  remark: string
  fileList: FileListType[]
  detailList: ProductDetailReq[]
  deliveryMethod: string
}
export interface DeliveryRes {
  currentPage?: number
  pageSize?: number
  totalPage?: number
  totalCount?: number
  list: DeliveryResItem[]
}
export interface DeliveryResItem {
  deliveryOrderId?: string
  deliveryOrderCode?: string
  customerId: string
  customerName: string
  deliveryDate: string
  isInclTax: number
  sellersName: string
  sellersId: string
  transportCarNo: string
  invoiceStatus: string
  remark: string
  detailList: ProductDetailReq[]
  createdBy: string
  createdDt: string
  updatedBy: string
  updatedDt: string
  fileList: FileListType[]
  deliveryMethod: string
  index?: number // 导出的序号
  contactName: string
  customerAddress: string
  contactPhone: string
  totalAmt?: number
}
export interface DeliveryResHanldeItem {
  deliveryOrderId?: string
  deliveryOrderCode?: string
  customerId: string
  customerName: string
  deliveryDate: string
  isInclTax: number
  sellersName: string
  sellersId: string
  transportCarNo: string
  invoiceStatus: string
  remark: string
  createdBy: string
  createdDt: string
  updatedBy: string
  updatedDt: string
  fileList: FileListType[]
  deliveryMethod: string
  index?: number // 导出的序号
  contactName: string
  customerAddress: string
  contactPhone: string

  deliveryOrderDetailId?: string
  deliveryOrderIdz?: string
  materialStockId?: string
  qty?: number
  unitPrice?: number
  amt?: number
  productName?: string
  productCategory?: string
  unit?: string
  materialName?: string
  spec?: string
  materialCode?: string
  materialDesc?: string
  fluteType?: string
  crimpLine?: string
  outboundStatus?: number
}
export interface DeliveryListSearch {
  deliveryOrderCode?: string
  customerName?: string
  deliveryDate?: string[]
  sellersName?: string
  transportCarNo?: string
  invoiceStatus?: string
  createdStartDate?: string
  createdEndDate?: string
  deliveryStartDate?: string
  deliveryEndDate?: string
  materialName?: string
  isInclTax?: number
  isVoid?: number
}

export interface outWarehouseDelivery {
  materialStockId: string
  stockQty: number
  deliveryOrderDetailId: string
}
export function editDelivery(data: DeliveryReq) {
  return axios.post<DeliveryRes>(modelUrl + '/deliveryOrderAdit', data)
}

export function delDelivery(data: { deliveryOrderId: string }) {
  return axios.post<object>(modelUrl + '/deliveryOrderDel', data)
}

export function deliveryOrderVoid(data: { deliveryOrderId: string }) {
  return axios.post<object>(modelUrl + '/deliveryOrderVoid', data)
}

export function getDeliveryDetail(data: { deliveryOrderId: string }) {
  return axios.post<DeliveryResItem>(modelUrl + '/deliveryOrderDetail', data)
}

export function getDeliveryAllList(data?: DeliveryListSearch) {
  return axios.post<DeliveryRes>(modelUrl + '/deliveryOrderList', data)
}

export function getDeliveryPageList(data?: DeliveryListSearch) {
  return axios.post<DeliveryRes>(modelUrl + '/deliveryOrderPage', data)
}

export function batchOutWarehouseDelivery(data: outWarehouseDelivery[]) {
  return axios.post<DeliveryRes>(modelUrl + '/deliveryMaterialStockBatchAdd', data)
}

// 退货补货
export interface ReturnReissueReq {
  returnReissueId?: string
  deliveryOrderId: string
  deliveryOrderCode: string
  customerId: string
  customerName: string
  isInclTax: number
  directorBy: string
  remark: string
  detailList: ReturnReissueProductDetail[]
}
export interface ReturnReissueRes {
  currentPage?: number
  pageSize?: number
  totalPage?: number
  totalCount?: number
  list: ReturnReissueResItem[]
}
export interface ReturnReissueProductDetail {
  deliveryOrderDetailId: string
  materialStockId: string
  questionDesc: string
  returnProcess: string
  qty: number
  unitPrice: number
  amt: number
  processResult: string
  processSuggestion: string
  directorBy: string
  remark: string
  productName: string
  productCategory: string
  unit: string
  materialName: string
  spec: string
  materialCode: string
  materialDesc: string
  fluteType: string
  crimpLine: string
}
export interface ReturnReissueResItem {
  returnReissueId: string
  deliveryOrderId: string
  deliveryOrderCode: string
  customerId: string
  customerName: string
  isInclTax: number
  directorBy: string
  remark: string
  detailList: ReturnReissueProductDetail[]
  createdBy: string
  createdDt: string
  updatedBy: string
  updatedDt: string
  index?: number // 导出的序号
}
export interface ReturnReissueListSearch {
  deliveryOrderCode?: string
  customerName?: string
  isInclTax?: number
  directorBy?: string
  createdStartDate?: string
  createdEndDate?: string
}
export function editReturnReissue(data: ReturnReissueReq) {
  return axios.post<ReturnReissueRes>(modelUrl + '/returnReissueAdit', data)
}

export function delReturnReissue(data: { returnReissueId: string }) {
  return axios.post<object>(modelUrl + '/returnReissueDel', data)
}

export function getReturnReissueDetail(data: { returnReissueId: string }) {
  return axios.post<ReturnReissueResItem>(modelUrl + '/returnReissueDetail', data)
}

export function getReturnReissueAllList(data?: ReturnReissueListSearch) {
  return axios.post<ReturnReissueRes>(modelUrl + '/returnReissueList', data)
}

export function getReturnReissuePageList(data?: ReturnReissueListSearch) {
  return axios.post<ReturnReissueRes>(modelUrl + '/returnReissuePage', data)
}
